home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / rm.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  67 lines

  1. ; $Id: rm.pro,v 1.2 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ; Copyright (c) 1991-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ;+
  7. ; NAME:
  8. ;    RM
  9. ; PURPOSE:
  10. ;    Perform formatted input of matrices stored in the IMSL/IDL
  11. ;    linear algebra storage scheme from the standard input stream.
  12. ; CATEGORY:
  13. ;    Linear Algebra
  14. ; CALLING SEQUENCE:
  15. ;    RM, A [, Rows, Columns]
  16. ; INPUTS:
  17. ;       A    - The named variable into which data will be stored.
  18. ;       Rows - The number of 'rows' in A.
  19. ;       Columns - The number of 'columns' in A.
  20. ; OUTPUTS:
  21. ;    None.
  22. ; COMMON BLOCKS:
  23. ;    None.
  24. ; MODIFICATION HISTORY:
  25. ;    13, September 1991, Written by AB (RSI), Mike Pulverenti (IMSL)
  26. ;    31, October   1991,                      Mike Pulverenti (IMSL)
  27. ;-
  28.  
  29. pro RM, A, rows, columns, double=dbl, complex=cmplx
  30.  
  31. on_error, 2        ; Return to caller on error
  32.  
  33. n = n_params()
  34. if (n ne 1) and (n ne 3) then message, 'Wrong number of arguments."
  35.  
  36. ;      If Rows and Columns were not given, then make sure a is 
  37. ;    defined.
  38. s = size(a)
  39. if ((n eq 1) and (s(0) eq 0))  then message, 'Argument must be defined as a an array if Rows and Columns are not supplied.'
  40. if ((n eq 1) and (s(0) gt 2)) then message, 'Array has too many dimensions.'
  41. ;
  42. if (n eq 1) then begin
  43.     a = transpose(a)
  44.     s = size(a)
  45.     l_columns = s(1)
  46.     if (s(0) eq 1) then l_rows=1 else l_rows=s(2)
  47.     type = s(s(0)+1)
  48. endif else begin
  49.     l_rows = rows
  50.     l_columns = columns
  51.     if keyword_set(cmplx) then $
  52.     type = 6 $
  53.     else if keyword_set(dbl) then type = 5 else type = 4
  54.     dbl = keyword_set(dbl)
  55.     cmplx = keyword_set(cmplx)
  56.     a = make_array(l_columns, l_rows, type=type)
  57. endelse
  58.  
  59. scratch = make_array(l_columns, 1, type=type)
  60. for i = 0, l_rows-1 do begin
  61.     read, string(i, format='("row ", I0, ": ")'), scratch
  62.     a(0, i) = scratch
  63. endfor
  64. a = transpose(a)
  65.  
  66. end
  67.